
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>SpringBoot项目启动成功后的初始化操作 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>SpringBoot项目启动成功后的初始化操作 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">@PostConstruct注解的作用是什么？它所标记的方法在Spring生命周期的哪个阶段被调用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">@PostConstruct注解用于标记一个需要在Bean初始化后执行的方法。该方法会在Spring容器初始化Bean之后被自动调用，用于执行初始化逻辑。</div>
          </div>
          <div class="card-source">来源: 1. 使用@PostConstruct注解</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如何使用 ApplicationRunner 接口在Spring Boot应用启动后执行自定义逻辑？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过创建一个实现 ApplicationRunner 接口的类，并实现其 run 方法。Spring Boot应用启动后，这个 run 方法会被自动调用，从而执行其中编写的初始化操作逻辑。</div>
          </div>
          <div class="card-source">来源: 2. 实现ApplicationRunner接口</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">CommandLineRunner 接口主要的应用场景有哪些？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">CommandLineRunner 接口可用于在Spring Boot应用启动后，执行一些特定的逻辑或任务，例如预加载数据、初始化资源、启动定时任务等。</div>
          </div>
          <div class="card-source">来源: 3. 实现CommandLineRunner接口</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">ApplicationListener<ContextRefreshedEvent> 监听的 ContextRefreshedEvent 事件是在什么条件下被触发的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当Spring容器完成刷新时，会触发 ContextRefreshedEvent 事件。这个时间点意味着所有的Bean都已经被初始化并装载到容器中。</div>
          </div>
          <div class="card-source">来源: 4. 实现ApplicationListener接口</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在Spring的启动流程中，@PostConstruct 注解标记的方法与由 ContextRefreshedEvent 事件触发的逻辑，哪一个会更先执行？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">@PostConstruct 注解标记的方法会先执行。文档说明，ContextRefreshedEvent 事件是在所有Bean被实例化、装载，并且初始化方法（例如@PostConstruct标记的方法）都已经执行完毕时，才会被触发。</div>
          </div>
          <div class="card-source">来源: 4. 实现ApplicationListener接口</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">文档中提到了哪些可以在Spring Boot应用启动后执行的通用初始化操作的例子？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到的通用初始化操作例子包括：初始化数据库、预热缓存、以及加载配置等。</div>
          </div>
          <div class="card-source">来源: 4. 实现ApplicationListener接口</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
